﻿if exists(select name from sysobjects where name = 'vMonthlyReport' and type = 'V')
drop View vMonthlyReport

Go

USE [NPMonitor]
GO

CREATE VIEW [vMonthlyReport]
AS
SELECT BeginTime,avg(time) AS AverageTime,LocationId,ScenarioNO
FROM (
		SELECT  PoolId AS LocationId, ScenarioNO, 
		CAST((CONVERT(VARCHAR(11), BeginTimeFormat, 120) + ' 00:00:00') AS DATETIME) AS BeginTime,
		Time FROM  dbo.HttpActions 
	) AS T WHERE T.ScenarioNO != ''
GROUP BY BeginTime,LocationId,ScenarioNO;





GO